package com.example.unveil_the_leader.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.unveil_the_leader.common.Result;
import com.example.unveil_the_leader.entity.Project;
import com.example.unveil_the_leader.service.ProjectService;
import com.example.unveil_the_leader.mapper.ProjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author XCT
* @description 针对表【project】的数据库操作Service实现
* @createDate 2024-01-26 15:58:16
*/
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project>
    implements ProjectService{

    @Autowired
    private ProjectMapper projectMapper;

    @Override
    public Result addProject(Project project) {
        Project projectByName = projectMapper.getMsgByName(project.getProjectName());
        if(projectByName!=null){
            return Result.error("200","当前项目名称已经存在，申请失败");
        }else{
            //4表示项目正在审核
            project.setProjectStatus(4);
            projectMapper.addProject(project);
            return Result.success("项目申请已经提交，等待管理员审核");
        }
    }

    /**
     * 项目修改需要在项目审核通过之前
     * */
    @Override
    public Result updateProject(Project project) {
        projectMapper.updateProject(project);
        return Result.success("项目修改信息已经提交，待管理员审核");
    }

    @Override
    public Result deleteProject(int id) {
        projectMapper.deleteProject(id);
        return Result.success("项目撤回成功");
    }

    @Override
    public Result findByName(String projectName) {
        return null;
    }

    @Override
    public Result findByClass(String projectClass) {
        return null;
    }
}




